package com.rxyb.rabbitmq;

import com.rxyb.rabbitmq.config.enums.QueueEnums;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author YJH
 * @version 1.0
 * @description
 * @date 2020/6/3  18:13
 */
@Service
public class SendQueue {


    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void send(String key, String content) {
        QueueEnums queueEnums = QueueEnums.fromCode(key);
        rabbitTemplate.convertAndSend(queueEnums.getExchange(), queueEnums.getQueue(), content);
    }
}
